package com.hd.crdao.adapter;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.hd.crdao.R;
import com.hd.crdao.base.MyBaseAdapter;
import com.hd.crdao.bean.ShopListBean;
import com.hd.crdao.config.Constants;
import com.hd.crdao.utils.UIUtils;
import com.hd.crdao.wrapper.GlideImageUtils;

import java.util.List;

/**
 *
 *@author Administrator
 *@date 2017/7/31 0031
 */

public class MyListViewAdapter extends MyBaseAdapter<ShopListBean.StoreInfoListBean> {


    public MyListViewAdapter(List<ShopListBean.StoreInfoListBean> dataSets) {
        super(dataSets);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder viewHolder;
        if (convertView == null) {
            viewHolder = new ViewHolder();
            convertView = View.inflate(UIUtils.getContext(), R.layout.shop_item, null);
            viewHolder.mShopLogo = (ImageView) convertView.findViewById(R.id.shop_logo);
            viewHolder.mStoreName = (TextView) convertView.findViewById(R.id.storeName);
            viewHolder.mStoreAddress = (TextView) convertView.findViewById(R.id.storeAddress);
            viewHolder.mCarTotal = (TextView) convertView.findViewById(R.id.carTotal);
            viewHolder.mCbName = (TextView) convertView.findViewById(R.id.cbName);
            convertView.setTag(viewHolder);
        }else {
            viewHolder = (ViewHolder)convertView.getTag();
        }
        ShopListBean.StoreInfoListBean storeInfoListBean = mDataSets.get(position);
        GlideImageUtils.loadImage(Constants.IMAGEURL+storeInfoListBean.getStoreLogo(),R.drawable.no_photob,viewHolder.mShopLogo);
        viewHolder.mStoreName.setText(storeInfoListBean.getStoreName());
        viewHolder.mStoreAddress.setText(storeInfoListBean.getStoreAddress());
        viewHolder.mCarTotal.setText(storeInfoListBean.getCarTotal()+"辆");
        viewHolder.mCbName.setText("车商: "+storeInfoListBean.getCarBusiness().getCbName());
        return convertView;
    }

    static class ViewHolder {
        ImageView mShopLogo;
        TextView mStoreName;
        TextView mStoreAddress;
        TextView mCarTotal;
        TextView mCbName;
    }
}
